<script setup>

import {Menu} from "@element-plus/icons-vue";
import {useRouter} from "vue-router";
import {ref} from "vue";

// 获取当前的路由组件
const vueRouter = useRouter();

// 当前的导航菜单(从路由生成)
const navMenu = ref([]);

vueRouter.getRoutes().forEach((route) => {
  if (route.meta && route.meta.title) {
    navMenu.value.push({
      title: route.meta.title,
      link: route.path,
    });
  }
});


</script>

<template>
  <div class="nav-header">
    <el-page-header title="BilibiliTetris" :icon="Menu">
      <template #content>
        <div class="nav-content">
          <div class="title-bar">
            <span class="title"> 小破站打块助手 </span>
            <span class="version" style="color: var(--el-text-color-regular)">Ver 1.0.0</span>
          </div>
          <div class="menu">
            <router-link v-for="item in navMenu" class="menu-link" :to="item.link">{{ item.title }}</router-link>
          </div>
        </div>
      </template>
    </el-page-header>
  </div>
</template>

<style scoped>

.nav-header {
  border-bottom: 1px solid #f2f2f2;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.nav-content {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-direction: column;

  .title-bar {
    .title {
      font-size: 14px;
      font-weight: 700;
    }

    .version {
      font-size: 12px;
      padding-left: 10px;
    }
  }

  .menu {
    font-size: 12px;

    .menu-link {
      color: #666;

      &:after {
        content: "|";
        padding: 0 10px;
        color: #d2d2d2;
      }

      &:last-child:after {
        content: "";
      }
    }
  }

}
</style>
